﻿using UnityEngine;

namespace UnknowWorld.CardGame
{
    /// <summary>
    /// 卡牌效果
    /// </summary>
    [System.Serializable]
    public class CardEffect
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        public string Key { get; set; }
        /// <summary>
        /// 说明
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 类型
        /// </summary>
        public EffectType Type { get; set; }

        /// <summary>
        /// 使用效果
        /// </summary>
        public void Use(bool isPlayer,int value)
        {
            var cgc = GameObject.FindObjectOfType<CardGameControl>();
            if (cgc)
            {
                switch (Type)
                {
                    case EffectType.EnemyBloodMinus:
                        if (isPlayer)
                            cgc.Enemey.Hurt(value);
                        else
                            cgc.Player.Hurt(value); ;
                        break;
                }
            }
        }

        /// <summary>
        /// 格式化描述
        /// </summary>
        /// <returns></returns>
        public string FormatDescription(int value)
        {
            var des = string.Format("\n\u3000>{0}", Description.Replace("#value#", value.ToString()));
            return des;
        }
    }

    /// <summary>
    /// 卡牌效果类型
    /// </summary>
    [System.Serializable]
    public enum EffectType
    {
        /// <summary>
        /// 敌方减血
        /// </summary>
        EnemyBloodMinus,
        /// <summary>
        /// 敌方加血
        /// </summary>
        EnemyBloodAdd,
        /// <summary>
        /// 自己减血
        /// </summary>
        SelfBloodMinus,
        /// <summary>
        /// 自己加血
        /// </summary>
        SelfBloodAdd,

        /// <summary>
        /// 敌方减能量
        /// </summary>
        EnemyEnergyMinus,
        /// <summary>
        /// 敌方加血能量
        /// </summary>
        EnemyEnergyAdd,
        /// <summary>
        /// 自己减血能量
        /// </summary>
        SelfEnergyMinus,
        /// <summary>
        /// 自己加血能量
        /// </summary>
        SelftEnergyAdd,

        /// <summary>
        /// 敌方抽卡
        /// </summary>
        EnemyCardAdd,
        /// <summary>
        /// 敌方弃卡
        /// </summary>
        EnemyCardMinus,
        /// <summary>
        /// 敌发移除卡
        /// </summary>
        EnemyCardDelete,
        /// <summary>
        /// 自己抽卡
        /// </summary>
        SelfCardAdd,
        /// <summary>
        /// 自己弃卡
        /// </summary>
        SelfCardMinus,
        /// <summary>
        /// 敌发移除卡
        /// </summary>
        SelfCardDelete,

        /// <summary>
        /// 增加自己攻击
        /// </summary>
        SelftAttackAdd,
        /// <summary>
        /// 增加敌方攻击
        /// </summary>
        EnemyAttackAdd,
        /// <summary>
        /// 减少自己攻击
        /// </summary>
        SelftAttackMinus,
        /// <summary>
        /// 减少敌方攻击
        /// </summary>
        EnemyAttackMinus,
    }
}